package com.yuanrui.subject.application.controller;

import com.yuanrui.subject.common.entity.PageResult;
import com.yuanrui.subject.infra.basic.entity.SubjectInfoEs;
import com.yuanrui.subject.infra.basic.service.SubjectEsService;
import com.yuanrui.subject.infra.entity.UserInfo;
import com.yuanrui.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/testFeign/")
public class TestFeignController {

    @Resource
    private UserRpc userRpc;

    @Resource
    private SubjectEsService subjectEsService;
//    @Resource
//    private SubjectEsServiceImpl subjectEsServiceImpl;

    @RequestMapping("test")
    public void testFeign() {
        UserInfo yuan = userRpc.getUserInfo("ojRST6Q9-GZtipOCLgy4_8gln6tM");
        log.info("yuan:{}", yuan);
    }

//    @GetMapping("/createIndex")
//    public void testCreatIndex() {
//        subjectEsServiceImpl.createIndex();
//    }
//
//    @GetMapping("/addDocument")
//    public void addDoc() {
//        subjectEsServiceImpl.addDocument();
//    }
//
//    @GetMapping("/findDoc")
//    public void findDoc() {
//        subjectEsServiceImpl.findDocument();
//    }
//
//    @GetMapping("/searchDoc")
//    public void searchDoc() {
//        subjectEsServiceImpl.searchDocument();
//    }

    @PostMapping("/quertSubjectByKeyWord")
    public PageResult<SubjectInfoEs> quertSubjectByKeyWords() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyword("ikun");
        PageResult<SubjectInfoEs> subjectInfoEsPageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("subjectInfoEsPageResult:{}", subjectInfoEsPageResult);
        return subjectInfoEsPageResult;
    }
}
